package com.smart.wap.h5;

import com.smart.common.entities.ajax.AjaxResult;
import com.smart.common.entities.constant.SmartConstant;
import com.smart.manager.pop.entities.body.RDisQuestionnaire;
import com.smart.manager.pop.repository.DisQuestionnaireRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 会员资料信息接口
 *
 * @author Administrator
 */
@Api(tags = "公众号H5-分享问答")
@RestController
@RequestMapping(SmartConstant.WAP_API_PREFIX + "h5/questionnaire")
@RequiredArgsConstructor
@Log4j2
public class QuestionnaireController {

    private final DisQuestionnaireRepository disQuestionnaireRepository;

    @PostMapping(value = "add")
    @ApiOperation(value = "新增问卷记录")
    public AjaxResult<String> add(@RequestBody @Validated RDisQuestionnaire.EditBody body) {
        String add = disQuestionnaireRepository.add(body);
        return AjaxResult.data(add);
    }
    @PostMapping(value = "addSubstance/{id}")
    @ApiOperation(value = "新增问卷内容")
    public AjaxResult<String> addSubstance(@PathVariable Long id,@RequestBody @Validated RDisQuestionnaire.EditBody2 body) {
        String add = disQuestionnaireRepository.addSubstance(id,body);
        return AjaxResult.data(add);
    }

    @PostMapping(value = "getCode")
    @ApiOperation(value = "获取手机验证码", notes = SmartConstant.NOT_NEED_TOKEN)
    public AjaxResult<String> getSmsCode(@RequestBody @Validated RDisQuestionnaire.EditBody3 form) {
        disQuestionnaireRepository.getCaptcha(form);
        return AjaxResult.success();
    }

}
